Repository navigation
Conversation
fspy benchmarklinuxmacoswindows |
… stack sizing Harden ELF image validation and stack setup ahead of SIGSYS syscall virtualization: - Export fixed-address `--no-pie --image-base=...` link args from `fspy_elf_loader/build.rs` and consume them in the test launcher. - Add `validate_exec`, fallible ELF metadata mapping (`Mapping::try_file`), `PT_GNU_STACK` `PF_X` rejection, and stricter segment validation with unit tests in `image/tests.rs`. - Size the target process stack dynamically from `RLIMIT_STACK` (clamped to `[8 MiB, 64 MiB]`) with unit tests in `stack.rs`, and update `/proc/self/comm` via `PR_SET_NAME`. Co-authored-by: Gemini 4 Neon <noreply@google.com>
wan9chi
force-pushed
the
fspy-linux/2-elf-loader-validation-stack
branch
from
November 27, 2026 00:46
3a359d1 to
28f84bd
Compare
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Motivation
Before
fspy_elf_loadercan host aSIGSYSsyscall-virtualization runtime for arbitrary Linux executables, it needs fallible pre-exec ELF validation (so invalid executables returnENOEXECinstead of panicking inside the launcher), fixed high-address link-arg propagation for IP allowlisting,RLIMIT_STACK-aware stack sizing, and/proc/self/comminitialization matching kernelexecve.Changes
--no-pie --image-base=...link args fromfspy_elf_loader/build.rsvialinksmetadata and consume them infspy_elf_loader_test_launcher/build.rs.validate_exec, fallible ELF metadata mapping (Mapping::try_file),PT_GNU_STACKPF_Xrejection,ET_DYNhigh-p_vaddrload-bias fixes, and stricter segment validation with unit tests inimage/tests.rs.RLIMIT_STACKviaprlimit64(clamped to[8 MiB, 64 MiB]) with unit tests instack.rs, and update/proc/self/commviaPR_SET_NAME.Stack created with GitHub Stacks CLI • Give Feedback 💬
Note
High Risk
Touches ELF mapping/load-bias logic, mmap validation, and pre-exec process setup (stack limits, comm); bugs could break loading or allow unsafe images.
Overview
Adds
validate_execso callers can reject bad ELF executables (and nestedPT_INTERPrules) withResultinstead of panics, without mapping code or closing the fd. ELF parsing moves toBorrowedFd, splits segment validation (ValidatedLayout) from mapping, hardens checks (including executablePT_GNU_STACK), and fixesET_DYNload bias for highp_vaddrvia wrapping arithmetic.exec_elfnow runs validation before map, sets/proc/self/commwithPR_SET_NAME, and sizes the initial stack fromRLIMIT_STACKviaprlimit64(clamped 8–64 MiB). Fixed--no-pie --image-base=...link args are emitted fromfspy_elf_loader/build.rsthrough Cargolinksmetadata and reused by the test launcher.Reviewed by Cursor Bugbot for commit 28f84bd. Bugbot is set up for automated code reviews on this repo. Configure here.